package data.datas;

import java.io.IOException;
import java.util.List;

import network.e2e.FrameWriter;

import stalker.Stalker;
import data.Data;
import data.content.Content;

/**
 * Mutable class that contains a collection of data
 */

public abstract class Datas {
  
  /**
   * Mutate this by appending a data to the end of this collection
   * @requires all parameters not null
   */
  public abstract void addData(Stalker creator, Content content);
  
  /**
   * Retrieves the latest data in this collection
   * @requires collection is not empty
   * @return The last data added to the collection
   */
  public abstract Data retrieveLatestData();
  
  /**
   * Retrieves all datas from this collection
   * @return all the datas in this collection
   */
  public abstract List<Data> retrieveAllDatas();
  
  /**
   * Appends a data to the appropriate location
   * @requires data not null
   * @param data the data to be inserted
   */
  public abstract void insertData(Data data);
  
  /**
   * Checks whether the collection contains no data
   * <p>
   * For downward compatibility only
   * @return true iff the collection contains no data
   */
  public abstract boolean isEmpty();
  
  /**
   * Sent this through the net
   * @requires writer not null
   * @param writer the net
   */
  public abstract void send(FrameWriter writer) throws IOException;
  
}
